class IUP_RADIO
-- Creates a void container for grouping mutual exclusive toggles. Only one 
-- of its descendent toggles will be active at a time. The toggles can be at 
-- any composition.
--
-- It does not have a native representation. 

inherit
	IUP_CONTAINER
	IUP_WIDGET_EXPAND
	IUP_WIDGET_WID
	IUP_WIDGET_FONT
	IUP_WIDGET_CLIENTSIZE
	IUP_WIDGET_CLIENTOFFSET
	IUP_WIDGET_POSITION
	IUP_WIDGET_MAXMIN_SIZE
	IUP_WIDGET_VISIBLE
	IUP_WIDGET_CHILD
	IUP_WIDGET_NAME
	IUP_WIDGET_CUSTOM_ATTRIBUTES

create {ANY}
	radio_empty,
	radio	

feature {ANY}

	radio_empty
	   -- Create an empty radio
		local
			p, a_radio: POINTER
		do
			a_radio := int_radio (p)
			set_widget(a_radio)
		end
	
	radio (child: IUP_WIDGET)
	   -- Create a new radio containing the widget.
		local
         a_radio: POINTER
		do
			a_radio := int_radio (child.widget)
			set_widget(a_radio)
		end

	-- Attributes

	set_value (name: STRING)
		-- (non inheritable): The visible child accessed by its name. The value 
		-- passed must be the name of one of the children contained in the zbox. 
		-- Use set_attribute_handle to associate a child to a name. When the 
		-- value is changed the selected child is made visible and all other 
		-- children are made invisible, regardless their previous visible state.
		do
			iup_open.set_attribute(Current, "VALUE", name)
		end
	
	get_value: STRING
		-- Return the name of the visible child.
		do
			Result := iup_open.get_attribute(Current, "VALUE")
		end

	set_value_widget (wgt: IUP_WIDGET)
		-- (non inheritable): The visible child accessed by its handle. The 
		-- value passed must be the handle of a child contained in the zbox. 
		-- When the zbox is created, the first element inserted is set as the 
		-- visible child.
		do
			iup_open.set_attribute_widget(Current, "VALUE_HANDLE", wgt)
		end

	get_value_widget: IUP_WIDGET
		-- Return the IUP_WIDGET that is visible.
		do
			Result := iup_open.get_attribute_widget(Current, "VALUE_HANDLE")
		end

feature {}

	-- Internal
	
	int_radio (child: POINTER): POINTER
		external "plug_in"
      alias "{
         location: "${sys}/plugins"
         module_name: "iup"
         feature_name: "IupRadio"
         }"
      end

end

-- The MIT License (MIT)

-- Copyright (c) 2016, 2017 by German A. Arias

-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in 
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
